There are many scenario where access developers wants to extract information from particular URL and to use that information to accomplish their business requirement. For instance using this information to know keywords related to that URL. This article use a very simple process to accomplish this requirement. As shown in figure below in order to complete this functionality first of all create a simple form along with few controls over it.
Fig:-1.1
As shown in figure above form named frmSearchKeywords contains a text box to accept an URL path that will be processed. Another sub form named subfrmKeywords will be used to store extracted information. Above that sub form there is a button with Caption Clear to clear stored information.
In next step, In order to complete this functionality we need to explicitly set the reference to Microsoft XML, V 6.0 Initially user will be asked to enter URL into corresponding text box. Shown in figure below.
Fig:-1.2
When user enter's URL in text box and Click on View Source Button process got initiated and subsequently entire page source listed as shown in figure below.
Fig:-1.3
In last step to complete above process associate VBA Code with On Click Event of button named View Source
VBA Code:-
Private Sub cmdClr_Click() Me.subfrmKeywords.Controls ("tblKeywords") = Null End Sub Private Sub cmdKeyword_Click() On Error GoTo Errhndlr DoCmd.Hourglass True Dim ResultantURLContent As XMLHTTP60, strurl As String strurl = Me.txturl Set ResultantURLContent = GetPage(strurl) Me.subfrmKeywords.Controls ("tblKeywords") = ResultantURLContent.responseText DoCmd.Hourglass False Exit Sub Errhndlr: DoCmd.Hourglass False MsgBox "Enter URL" End Sub Public Function GetPage(sLink As String) As XMLHTTP60 Dim ResultantObj As MSXML2.XMLHTTP60 Set ResultantObj = New MSXML2.ServerXMLHTTP60 ResultantObj.Open "GET", sLink, False ResultantObj.send "" Set GetPage = ResultantObj End Function Private Sub Form_Open() ' Code associated with On Open Event of form frmSearchKeywords MsgBox "Enter URL to View Page Source", vbInformation, "Information" End Sub
DISCLAIMER
It is advised that the information provided in the article should not be used for any kind formal or production programming purposes as content of the article may not be complete or well tested. ERP Makers will not be responsible for any kind of damage (monetary, time, personal or any other type) which may take place because of the usage of the content in the article.